package person.bing.fbcloud.leetcode;

/**
 * @author: mengfanbing
 * @date: 2020/8/24 10:08
 */
public class Q459 {
    public static void main(String[] args) {
        String s = "ababab";
        boolean ans = repeatedSubstringPattern(s);
        System.out.println(ans);

    }

    //1.spilt后的数组长度为0（有点慢）
    public static boolean repeatedSubstringPattern(String s) {
        int length = s.length();
        for (int i=0;i<length/2;i++){
            String substring = s.substring(0, i+1);
            int remain = length % (i+1);
            if (remain == 0){
                String[] split = s.split(substring);
                if (split.length == 0){
                    return true;
                }
            }
        }
        return false;
    }
}
